package com.baoyouqun.domain.VO;

import com.baoyouqun.domain.Enum.SystemConfigType;
import com.baoyouqun.entity.SystemConfig;
import lombok.Data;

@Data
public class UserAgreementDTO {

    private String id;
    private String htmlContent;  // 对应info6：用户协议HTML内容

    // SystemConfig转DTO
    public static UserAgreementDTO fromSystemConfig(SystemConfig config) {
        if (config == null || !SystemConfigType.USER_AGREEMENT.equals(config.getConfigType())) {
            return null;
        }
        UserAgreementDTO dto = new UserAgreementDTO();
        dto.setId(config.getId());
        dto.setHtmlContent(config.getInfo8());
        return dto;
    }

    // DTO转SystemConfig
    public SystemConfig toSystemConfig(SystemConfig config) {
        config.setId(id);

        config.setConfigType(SystemConfigType.USER_AGREEMENT);
        config.setConfigName(SystemConfigType.USER_AGREEMENT.getDesc());
        config.setInfo8(htmlContent); // HTML内容存info6
        return config;
    }
}